package route;

public class ConsDistance extends ALoDistance {
	private Segment first;
	private ALoDistance rest;

	public ConsDistance(Segment first, ALoDistance rest) {
		this.first = first;
		this.rest = rest;
	}

	@Override
	public String toString() {
		return this.first + " " + this.rest;
	}

	@Override
	public boolean passAcross(String roadName) {

		return this.first.passAcross(roadName)
				|| this.rest.passAcross(roadName);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null || obj instanceof ConsDistance)
			return false;
		else {
			return this.first.equals(first) && this.rest.equals(rest);
		}
	}

	@Override
	public double howlong() {
		
		return this.first.getDistance()+this.rest.howlong();
	}
}
